#ifndef CAPSCREEN_H
#define CAPSCREEN_H
#include <QWidget>
#include <QPaintEvent>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QRect>
#include <QShowEvent>


typedef  struct MousePoint{
    QPoint start;  // 起始位置
    QPoint end;    // 结束位置
}mousePoint;

class CapScreen: public QWidget{
    Q_OBJECT // 信号和槽相关函数
public:
    CapScreen(QWidget *parent =nullptr);
    ~CapScreen();

protected:
    void showEvent(QShowEvent *) override;
    void paintEvent(QPaintEvent *qp) override;            // 重载paintEvent
    void mousePressEvent(QMouseEvent *menevt) override;   // 获取鼠标按压事件
    void mouseMoveEvent(QMouseEvent *menevt) override;    // 获取鼠标按下后并移动事件
    void mouseReleaseEvent(QMouseEvent *menevt)override;  // 鼠标按下后释放事件
//    void keyPressEvent(QKeyEvent *event) override;          // 重载keyPressEvent
    void keyReleaseEvent(QKeyEvent *event) override;         // 重载keyPressEvent

signals:
    void signalShotPixmap(QPixmap shotPix);


private:
    QPixmap mCapPix;  // 截图
    QPixmap mBlurPix; // 模糊
    QPixmap mFullPix;  // 全屏

    mousePoint mPos;  // 截图起始和结束点
    QRect mRect;      // 截图矩形

    bool  isMousePress; // 是否按下鼠标

    QKeyEvent *mKey; // 键盘
    bool   isKeyRelease;  // 键盘是否按下
    bool   isKeyEnsure; // 是否确认
    bool   isKeyCancel; // 是否取消
};

#endif // CAPSCREEN_H
